﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace Developex.DatabaseWrapper
{
	/// <summary>
	/// Default database error handler
	/// </summary>
	/// <remarks>
	/// Throw exception on database error in DEBUG mode
	/// Write in Trace errors and warnings
	/// </remarks>
	public class DefaultDatabaseErrorHandler : IDatabaseErrorHandler
	{
		/// <summary>
		/// Process database exception
		/// </summary>
		/// <param name="exception"></param>
		public virtual void OnDatabaseException(DatabaseException exception)
		{
			Trace.Write(exception.ToString());
#if DEBUG
			throw exception;
#endif
		}

		/// <summary>
		/// Process database warning
		/// </summary>
		/// <param name="warning"></param>
		public virtual void OnDatabaseWarning(DatabaseWarning warning)
		{
			Trace.Write(warning.ToString());
		}
	}
}
